package com.xiaolu.xiaoluaicodebackend.service;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import com.xiaolu.xiaoluaicodebackend.model.dto.user.UserQueryRequest;
import com.xiaolu.xiaoluaicodebackend.model.entity.User;
import com.xiaolu.xiaoluaicodebackend.model.vo.LoginUserVO;
import com.xiaolu.xiaoluaicodebackend.model.vo.UserVO;
import jakarta.servlet.http.HttpServletRequest;

import java.util.List;

/**
 * 用户 服务层。
 *
 * @author <a href="https://github.com/xiaolu236532">小鹿程序员</a>
 */
public interface UserService extends IService<User> {

    /**
     * 用户注册
     * @param userEmail
     * @param codeKey
     * @param codeValue
     * @return
     */
    long userRegister(String userEmail, String codeKey, String codeValue);

    /**
     * 发送邮箱注册码
     * @param userEmail
     * @return
     */
    String sendEmailCode(String userEmail);

    /**
     * 用户登录
     * @param userAccount
     * @param userPassword
     * @param captchaKey
     * @param captchaCode
     * @param request
     * @return
     */
    LoginUserVO userLogin(String userAccount, String userPassword, String captchaKey, String captchaCode, HttpServletRequest request);

    /**
     * 获取当前登录用户
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);


    /**
     * 用户注销
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request);

    /**
     *
     * 获取脱敏用户列表
     * @param userList
     * @return
     */
    List<UserVO> getUserVoList(List<User> userList);

    /**
     * 获取用户条件
     * @param userQueryRequest
     * @return
     */
    QueryWrapper getQueryWrapper(UserQueryRequest userQueryRequest);


    UserVO getUserVO(User user);

    boolean isAdmin(User user);

    /**
     *  MD5加密
     * @param userPassword
     * @return
     */
    String getEncryptPassword(String userPassword);




}
